

package com.hazelcast.internal.monitor.impl;

import com.hazelcast.query.impl.IndexHeapMemoryCostUtil;

/**
 * The implementation of operation index stats specialized for global indexes.
 */
public class GlobalIndexOperationStats implements IndexOperationStats {

    private long entryCountDelta;

    private long memoryCostDelta;

    @Override
    public long getEntryCountDelta() {
        return entryCountDelta;
    }

    @Override
    public long getMemoryCostDelta() {
        return memoryCostDelta;
    }

    @Override
    public void onEntryAdded(Object addedValue) {
        ++entryCountDelta;
        memoryCostDelta += IndexHeapMemoryCostUtil.estimateValueCost(addedValue);
    }

    @Override
    public void onEntryRemoved(Object removedValue) {
        --entryCountDelta;
        memoryCostDelta -= IndexHeapMemoryCostUtil.estimateValueCost(removedValue);
    }

}
